package com.liujit.pay.wx.domain.params.order;

import cn.hutool.json.JSONObject;
import lombok.Builder;

/**
 * @description: 订单金额
 * @author: liujun
 * @create: 2021-02-20 09:39
 */
@Builder
public class OrderAmount {

    /**
     * 订单总金额，单位为分
     */
    private Integer total;

    /**
     * 初始化参数
     *
     * @param total 订单总金额
     * @return
     */
    public static OrderAmount.Builder builder(Integer total) {
        return new OrderAmount.Builder(total);
    }

    public static class Builder {

        private Integer total;

        Builder(Integer total) {
            this.total = total;
        }

        public OrderAmount build() {
            return new OrderAmount(this.total);
        }
    }

    /**
     * 转化JSON字符串
     *
     * @return
     */
    public String toJSONString() {
        JSONObject json = new JSONObject();
        // 总金额
        json.set("total", total);
        // 货币类型
        json.set("currency", "CNY");
        return json.toString();
    }
}
